class AddMoreArtistsAndImagesToEachRegion < ActiveRecord::Migration
  def self.up
    Artist.create :name => "Julie Testlady", :region => Region.find_by_name('Yakima'), :hometown => "Yakima", :age => 49, :map_lat => 46.604639, :map_lon => -120.506973, :map_zoom => 12, :published => true
    Artist.create :name => "John Doe", :region => Region.find_by_name('Mexico'), :published => true, :map_lat => 21.534847, :map_lon => -101.821289, :map_zoom => 5

    ArtistDescription.create :artist => Artist.find_by_name('Julie Testlady'), :biography => "I'm Julie!", :personal_statement => "I love art!", :language => "English"
    ArtistDescription.create :artist => Artist.find_by_name('Julie Testlady'), :biography => "Soy Julie!", :personal_statement => "Me gusta arte!", :language => "Spanish"
    ArtistDescription.create :artist => Artist.find_by_name('John Doe'), :biography => "He started making art at a very young age..", :language => "English"

    Picture.create :artist => Artist.find_by_name('Julie Testlady'), :file => File.new(File.join(RAILS_ROOT, 'db', 'migrate', 'files', 'artst_01.jpg')), :media_type => Media::TYPE_PICTURE, :caption => 'test image'
    Picture.create :artist => Artist.find_by_name('John Doe'), :file => File.new(File.join(RAILS_ROOT, 'db', 'migrate', 'files', 'theojansenbig.jpg')), :media_type => Media::TYPE_PICTURE, :caption => 'test image'

    Artwork.create :name=> "Painting", :price => "35.00", :artist => Artist.find_by_name('Julie Testlady'), :published => true
    Artwork.create :name=> "Sculpture", :price => "50000.00", :artist => Artist.find_by_name('John Doe'), :published => true

    ArtworkDescription.create :artwork => Artwork.find_by_name('Painting'), :description => "A water painting", :language => "English"
    ArtworkDescription.create :artwork => Artwork.find_by_name('Sculpture'), :description => "Sand beast", :language => "English"
    ArtworkDescription.create :artwork => Artwork.find_by_name('Sculpture'), :description => "Sand beest", :language => "Dutch"
    
    Picture.create :artwork => Artwork.find_by_name('Painting'), :file => File.new(File.join(RAILS_ROOT, 'db', 'migrate', 'files', 'reflexos.jpg')), :media_type => Media::TYPE_PICTURE, :caption => 'test image'
    Picture.create :artwork => Artwork.find_by_name('Sculpture'), :file => File.new(File.join(RAILS_ROOT, 'db', 'migrate', 'files', 'jansen.jpg')), :media_type => Media::TYPE_PICTURE, :caption => 'test image'
  end

  def self.down
    ArtistDescription.delete(ArtistDescription.find_by_artist_id(Artist.find_by_name('Julie Testlady').id))
    ArtistDescription.delete(ArtistDescription.find_by_artist_id(Artist.find_by_name('John Doe').id))

    Picture.delete(Picture.find_all_by_artist_id(Artist.find_by_name('Julie Testlady').id))
    Picture.delete(Picture.find_all_by_artist_id(Artist.find_by_name('John Doe').id))
        
    ArtworkDescription.delete(ArtworkDescription.find_all_by_artwork_id(Artwork.find_by_name('Painting').id))
    ArtworkDescription.delete(ArtworkDescription.find_all_by_artwork_id(Artwork.find_by_name('Sculpture').id))
    
    Picture.delete(Picture.find_by_artwork_id(Artwork.find_by_name('Painting').id))
    Picture.delete(Picture.find_by_artwork_id(Artwork.find_by_name('Sculpture').id))
    
    Artist.delete(Artist.find_by_name("Julie Testlady"))
    Artist.delete(Artist.find_by_name("John Doe"))
    
    Artwork.delete(Artwork.find_by_name("Painting"))
    Artwork.delete(Artwork.find_by_name("Sculpture"))
  end
end
